<template>
  <div class="rightsContainer" style="width: 100%;">
    <!-- 面包屑导航栏 -->
     <div class="el-header">
        <el-menu router background-color="#eee" text-color="#303133" class="el-menu-demo" mode="horizontal">
          <el-menu-item index="/home">首页</el-menu-item>
          <el-menu-item>店铺管理权益</el-menu-item>
        </el-menu>
      </div>
    <el-form>
      <!-- 权益分配表 -->
      <el-card class="box-card first-card">
        <div slot="header" class="clearfix">
          <span>一级权益 :</span>
        </div>
        <div>
          <span>可上架商品数量 : </span><el-input v-model="firstRights.num" class="input"></el-input><span class="ge">个</span><el-input v-model="firstRights.money" class="input"></el-input
          ><span class="yuan">元/年</span><span class="shu"></span><span>优惠价</span><el-input v-model="firstRights.preferential_price" class="input"></el-input><span>元/年</span>
        </div>
      </el-card>

      <el-card class="box-card second-card">
        <div slot="header" class="clearfix">
          <span>二级权益 :</span>
        </div>
        <div>
          <span>可上架商品数量 : </span><el-input v-model="secondRights.num" class="input"></el-input><span class="ge">个</span><el-input v-model="secondRights.money" class="input"></el-input
          ><span class="yuan">元/年</span><span class="shu"></span><span>优惠价</span><el-input v-model="secondRights.preferential_price" class="input"></el-input><span>元/年</span>
        </div>
      </el-card>

      <el-card class="box-card last-card">
        <div slot="header" class="clearfix">
          <span>三级权益 :</span>
        </div>
        <div>
          <span>可上架商品数量 : </span><el-input v-model="threeRights.num" class="input"></el-input><span class="ge">个</span><el-input v-model="threeRights.money" class="input"></el-input
          ><span class="yuan">元/年</span><span class="shu"></span><span>优惠价</span><el-input v-model="threeRights.preferential_price" class="input"></el-input><span>元/年</span>
        </div>
      </el-card>

      <!-- 保存按钮 -->
      <el-button type="primary" @click="onSubmit">保存</el-button>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'rightsIndex',
  props: {},
  data() {
    return {
      // 一级权益输入框绑定数据
      firstRights: {},

      // 二级权益输入框绑定数据
      secondRights: {},

      // 三级权益输入框绑定数据
      threeRights: {}
    }
  },
  created() {
    // 获取所有权益数据
    this.loadStoreRights()
  },

  components: {},

  computed: {},

  beforeMount() {},

  mounted() {},

  methods: {
    async loadStoreRights() {
      const { data } = await this.$http.get('/storeRights')
      this.firstRights = data[0]
      this.secondRights = data[1]
      this.threeRights = data[2]
    },
    // 点击保存提交数据
    async onSubmit() {
      // 更改一级权益的数据
      await this.$http.put('/storeRights/1', this.firstRights)

      // 更改二级权益的数据
      await this.$http.put('/storeRights/2', this.secondRights)

      // 更改三级权益的数据
      await this.$http.put('/storeRights/3', this.threeRights)
    }
  },

  watch: {}
}
</script>
<style lang='less' scoped>
.rightsContainer {
  .el-header{
    padding: 0;
  }
  .box-card {
    margin: 50px 50px 0;
    box-shadow: unset;
    border-color: #333;
    min-width: 1200px;
    font-size: 14px;

    /deep/ .el-card__header {
      border-bottom: unset;
    }
    /deep/ .el-card__body {
      position: relative;
      padding: 0 52px 20px;
    }

    .input {
      width: 70px;
      border: 1px solid #333;
      border-radius: 5px;
      margin: 0 8px;
    }

    /deep/ .el-input__inner {
      border: unset;
    }

    .ge {
      margin-right: 40px;
    }

    .yuan {
      margin-right: 60px;
    }

    .shu {
      display: inline-block;
      position: absolute;
      top: -3px;
      left: 457px;
      width: 1px;
      height: 45px;
      background-color: #333;
    }
  }

  /deep/ .el-button {
    background-color: #169bd5;
    border-color: #169bd5;
    margin: 25px 120px;
    padding: 12px 50px;
  }
}
</style>
